/********************************************************************************/
/********************************************************************************/

#ifndef TPM2_COMMAND_H
#define TPM2_COMMAND_H

enum dtype_tpm2_input{
	TYPE(TPM2_IN)=0x2110,
	TYPE(TPM2_OUT)=0x2120,
	TYPE(TPM2_HEAD)=0x2130,
	TYPE(TPM2_UTILS)=0x2140
};

enum subtype_tpm2_utils{
	SUBTYPE(TPM2_UTILS,INPUT)=0x01,
	SUBTYPE(TPM2_UTILS,OUTPUT),
	SUBTYPE(TPM2_UTILS,PIK_CERT)
};

enum subtype_tpm2_in{
	SUBTYPE(TPM2_IN,GetRandom)=0x7B010000,
	SUBTYPE(TPM2_IN,PCR_Read)=0x7E010000,
	SUBTYPE(TPM2_IN,PCR_Extend)=0x82010000,
	SUBTYPE(TPM2_IN,PCR_SetAuthValue)=0x83010000
};


enum subtype_tpm2_out{
	SUBTYPE(TPM2_OUT,GetRandom)=0x7B010000,
	SUBTYPE(TPM2_OUT,PCR_Read)=0x7E010000,
	SUBTYPE(TPM2_OUT,PCR_Extend)=0x82010000,
	SUBTYPE(TPM2_OUT,PCR_SetAuthValue)=0x83010000
};
//#include "tcm_types.h"

typedef struct tpm2_in_GetRandom{
	UINT16 tag;
	int    commandSize;
	int    commandCode;
	UINT16  bytesRequested;
}__attribute__((packed)) RECORD(TPM2_IN,GetRandom);

typedef struct tpm2_out_GetRandom{
	UINT16 tag;
	int    responseSize;
	int    responseCode;
	TPM2B_DIGEST randomBytes;
}__attribute__((packed)) RECORD(TPM2_OUT,GetRandom);

typedef struct tpm2_in_PCR_Extend{
	UINT16 tag;
	int    commandSize;
	int    commandCode;
	UINT32 pcrHandle;
	TPML_DIGEST digests;	
}__attribute__((packed)) RECORD(TPM2_IN,PCR_Extend);

typedef struct tpm2_out_PCR_Extend{
	UINT16 tag;
	int    responseSize;
	int    responseCode;
}__attribute__((packed)) RECORD(TPM2_OUT,PCR_Extend);

typedef struct tpm2_in_PCR_Read{
	UINT16 tag;
	int    commandSize;
	int    commandCode;
	TPML_PCR_SELECTION * pcrSelectionIn;	
}__attribute__((packed)) RECORD(TPM2_IN,PCR_Read);

typedef struct tpm2_out_PCR_Read{
	UINT16 tag;
	int    responseSize;
	int    responseCode;
	int    pcrUpdateCounter;
	TPML_PCR_SELECTION pcrSelectionOut;
	TPML_DIGEST pcrValues;	 
}__attribute__((packed)) RECORD(TPM2_OUT,PCR_Read);

typedef struct tpm2_utils_input
{
    int param_num;
    BYTE * params;
}__attribute__((packed)) RECORD(TPM2_UTILS,INPUT);

typedef struct tpm2_utils_output
{
    int param_num;
    BYTE * params;
}__attribute__((packed)) RECORD(TPM2_UTILS,OUTPUT);

#endif
